#include<iostream>
#include<opencv2/imgcodecs.hpp>
#include<opencv2/highgui.hpp>
#include<opencv2/imgproc.hpp>
#include<opencv2/objdetect.hpp>
#include<string>
#include<vector>
#include"func.h"

using namespace std;
using namespace cv;


int main()
{
    // cout<<"1"<<endl;

    VideoCapture cap(0);
    Mat img,erzhied,lvboed,resultimg;
    vector<Point> traj;
    bool firstf=1;

    while(1)
    {
        cap.read(img);                          //图像获取
        // imshow("img",img);

        

        erzhied=erzhihua(img);                  //图像二值化
        // imshow("erzhied",erzhied);

        lvboed=lvbo(erzhied);                   //图像滤波
        imshow("lvboed",lvboed);

        resultimg=shibie(lvboed,img,traj,firstf);      //色块识别、卡尔曼滤波预测位置
        

        for(size_t i=1;i<traj.size();++i)
        {
            line(resultimg,traj[i-1],traj[i],Scalar(255,0,255),10);
        }
       
        imshow("resultimg",resultimg);

        waitKey(1);
    }

    system("pause");
    return 0;

}
//